<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;
use DB;


use App\Models\Users;


class IndexController extends Controller
{
    //列表
    function List(){
    	//读取数据
		// $list = DB::table("users")->get();
		// var_dump($list);

        //通过model操作数据库
        $users=new Users();
        // var_dump($users);die();
        // dd($users);
        $list=$users->get();
        // dd($list);exit();

		return view("list",compact("list"));

    }

    //渲染添加页
    function Add(){
    	return view("add");

    }

    //执行添加操作
    function doAdd(Request $request){
        //接受数据
        // dd($request->all());
        $model= new Users();
        $result = $model->create($request->all());
        //跳转到列表页
        return redirect("/list");

    }
}
